<@realgodo.html loc="">
<div class="co_m ">
 	<div class="music">
		<ul class="m_head">
			<li class="alive"><a hidefocus>&nbsp;音乐 </a></li>
		</ul>
		<div class="m_list" id="player" style="display:none">
			<object type="application/x-shockwave-flash" data="${statics}/plugins/dewplayer/dewplayer.swf" width="200" height="20" id="dewplayer" name="dewplayer" >
				<param name="movie" value="dewplayer.swf" />
				<param name="flashvars" value="mp3=${statics}/plugins/dewplayer/mp3/theDown.mp3&amp;autostart=1&amp;autoreplay=1&amp;showtime=1" id="flashvarsId"/>
				<param name="wmode" value="transparent" />
			</object>
		</div>
		<div class="m_list">
			<#--<div class="m_bt"><input type="button" value=" 添加音乐 " /></div>-->
			<p class="m_l l"><span class="font13 vd_color9" id="title">添加音乐</span></p>
			<form name="saveForm" id="saveForm" action="${base}/user/music/index!save " method="post">
			<div class="m_add">
				<p>
					<p class="m_l l"><span class="font13 vd_color9">曲目:</span></p><p class="m_r l"><input type="text" name="name" id="music_name"/></p>
				</p>
				<p class="p_top all_clear">
					<p class="m_l l"><span class="font13 vd_color9">链接地址:</span></p><p class="m_r l"><textarea name="url" id="music_url"></textarea></p>
				</p>
				<p class="vd_clear vd_center">
					<p class="m_l l"></p>&nbsp;
					<input type="hidden" name="id" id="music_id" value=""/>
					<input type="button" value="试听"  class="m_btt" onclick="testPlay()"/>
					<input type="button" value="确定引用"  class="m_btt" onclick="saveMusic()"/>
					<input type="button" value="取消"  class="m_btt" onclick="resetForm()"/>
				</p>
			</div>
			</form>
			<div class="m_songlist all_clear" id="music_list">
			<#if musicPage?exists>
				<#list musicPage.result as music>
				<p class="all_clear">
					<div class="l font12 bga">
						${music_index+1}.<a href="#" onclick="playMp3('${music.url!}')">${music.name!}</a>
					</div>
					<div class="r  font12 bga">
						<a href="#" onclick="editMusic('${music.id?c}','${music.name!}','${music.url!}')">编辑</a>&nbsp;<a href="#" onclick="del('${music.id?c}')">删除</a>
					</div>
				</p>
				</#list>
			</#if>
			<@realgodo.pagination_user div="music_list" />
			</div>
			
		</div>
	</div>
 </div>
<script>
	function saveMusic(){
		var url=document.getElementById('music_url').value;
		var name=document.getElementById('music_name').value;
		if(url==null||url==""){
			alert("链接地址不能为空");
			return;
		}
		if(name==null||name==""){
			alert("曲目不能为空");
			return;
		}
		document.getElementById('saveForm').submit();
	}
	
	function testPlay(){
		var url=document.getElementById('music_url').value;
		if(url==null||url==""){
			alert("链接地址不能为空");
			return;
		}
		playMp3(url);
	}

	function resetForm(){
		document.getElementById('music_name').value="";
		document.getElementById('music_url').value="";
		document.getElementById('music_id').value="";
		document.getElementById('title').innerHTML="添加音乐";
	}
	function playMp3(url){
		document.getElementById('player').style.display="";
		document.getElementById('flashvarsId').value="mp3="+url+"&amp;autostart=1&amp;autoreplay=1&amp;showtime=1";
		document.getElementById('player').innerHTML=document.getElementById('player').innerHTML;
	}
	function editMusic(id,name,url){
		document.getElementById('music_name').value=name;
		document.getElementById('music_url').value=url;
		document.getElementById('music_id').value=id;
		document.getElementById('title').innerHTML="编辑音乐";
	}
	function del(o_id){
		if(window.confirm("确认删除该音乐引用吗?")){
			window.location.href="${base}/user/music/index!delete?id="+o_id;
		}
	}
</script>
</@realgodo.html>